package com.bulletelc.apollopre.module.test.recyclerviewtest;

import android.os.Bundle;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.MotionEvent;

import com.bulletelc.apollopre.R;
import com.bulletelc.apollopre.framework.BaseActivity;
import com.bulletelc.apollopre.utils.LogUtil;

import java.util.ArrayList;
import java.util.List;

/**
 * author: lhl
 * date  : 2017/11/23
 * desc  : recyclerView测试
 */

public class RecyclerActivity extends BaseActivity {
    private RecyclerView rv;
    private TestAdapter adapter;
    private List<Goods> goodsList;
    @Override
    public int getLayoutRes() {
        return R.layout.activity_test_recycler;
    }

    @Override
    public void assignViews() {
        rv = findView(R.id.rv);
    }

    @Override
    public void setListener() {
        rv.addOnItemTouchListener(new RecyclerView.OnItemTouchListener() {
            @Override
            public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {

                return false;
            }

            @Override
            public void onTouchEvent(RecyclerView rv, MotionEvent e) {
                LogUtil.i(e.toString());
            }

            @Override
            public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
                LogUtil.i("disallowIntercept："+disallowIntercept);
            }
        });


    }

    @Override
    public void initData(Bundle savedInstanceState) {
        goodsList = new ArrayList<>();
        goodsList.add(new Goods("http://mpic.tiankong.com/72c/6d1/72c6d1bb97c1e16fca3cfb807239216c/640.jpg@360h", "雷克雅末"));
        goodsList.add(new Goods("http://mpic.tiankong.com/72c/6d1/72c6d1bb97c1e16fca3cfb807239216c/640.jpg@360h", "雷克雅末"));
        goodsList.add(new Goods("http://mpic.tiankong.com/72c/6d1/72c6d1bb97c1e16fca3cfb807239216c/640.jpg@360h", "雷克雅末"));
        goodsList.add(new Goods("http://mpic.tiankong.com/72c/6d1/72c6d1bb97c1e16fca3cfb807239216c/640.jpg@360h", "雷克雅末"));
        goodsList.add(new Goods("http://mpic.tiankong.com/72c/6d1/72c6d1bb97c1e16fca3cfb807239216c/640.jpg@360h", "雷克雅末"));
        goodsList.add(new Goods("http://mpic.tiankong.com/72c/6d1/72c6d1bb97c1e16fca3cfb807239216c/640.jpg@360h", "雷克雅末"));
        goodsList.add(new Goods("http://mpic.tiankong.com/72c/6d1/72c6d1bb97c1e16fca3cfb807239216c/640.jpg@360h", "雷克雅末"));
        goodsList.add(new Goods("http://mpic.tiankong.com/72c/6d1/72c6d1bb97c1e16fca3cfb807239216c/640.jpg@360h", "雷克雅末"));
        goodsList.add(new Goods("http://mpic.tiankong.com/72c/6d1/72c6d1bb97c1e16fca3cfb807239216c/640.jpg@360h", "雷克雅末"));

        adapter = new TestAdapter(goodsList,this);
        rv.setAdapter(adapter);
        rv.setLayoutManager(new GridLayoutManager(this,2));
        rv.addItemDecoration(new DividerItemDecoration(this,DividerItemDecoration.VERTICAL));


    }
}
